/***********************************************************************
** Copyright (C) 2011 Anthony Naddeo <anthony.naddeo@gmail.com>
**
** This file is part of LinkedUp
**
** LinkedUp is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or
** (at your option) any later version.
**
** LinkedUp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this package; If not, see <http://www.gnu.org/licenses/>.
**
***********************************************************************/
import QtQuick 1.1
import com.meego 1.0
import "../components"

Item{
	id: root
	width: parent.width
	height: rootColumn.height + 30

	/**
	  Used to dynamically create a Section for recommendations
	  if there are any in the xml file
	  */
	RecommendationModel{
		id: recommendModel; xml: root.ListView.view.model.xml
		onStatusChanged: {
			if(status == XmlListModel.Ready && get(0))
				var sec = section.createObject(rootColumn, {"titleText":"Recommendations" ,"list": true, "listDelegate":(Qt.createComponent("RecommendationDelegate.qml")), "listModel":recommendModel })
		}
	}

	/**
	  Used to dynamically create a Section for positions
	  if there are any in the xml file
	  */
	PositionsModel{ // creates the positions sections if there are any positions
		id: positionModel; xml: root.ListView.view.model.xml
		onStatusChanged: {
			if(status == XmlListModel.Ready && get(0))
				var sec = section.createObject(rootColumn, {"titleText":"Positions", "list": true, "listDelegate":(Qt.createComponent("PositionsDelegate.qml")), "listModel":positionModel})
		}
	}

	/**
	  Used to dynamically create a Section for education
	  if there is any in the xml file
	  */
	EducationsModel{ // creates the education sections if there are any
		id: educationModel; xml: root.ListView.view.model.xml
		onStatusChanged: {
			if(status == XmlListModel.Ready && get(0))
				var sec = section.createObject(rootColumn, {"titleText":"Education" ,"list": true, "listDelegate":(Qt.createComponent("EducationsDelegate.qml")), "listModel":educationModel})
		}
	}



	Component{//for creating section as needed
		id: section
		Section{}
	}



	Column{
		id: rootColumn
		width: root.width
		spacing: 40

		Component.onCompleted: { //add the variable sections to the screen if they exist
			if(specialties)
				var spec = section.createObject(rootColumn, {"titleText": "Specialties", "contentText":specialties})
			if(interests)
				var ints = section.createObject(rootColumn, {"titleText": "Interests", "contentText":interests})
			if(honors)
				var hons = section.createObject(rootColumn, {"titleText": "Honors", "contentText":honors})
			if(associations)
				var assos = section.createObject(rootColumn, {"titleText": "Associations", "contentText":associations})
		}

		Row{
			id: row
			spacing: 10
			width: parent.width
			smooth: true

			Image {
				id: image
				height:  100
				width: height
				smooth: true
				source: pictureUrl || "qrc:///qml/images/profile-picture.png"
			}


			Column{
				width: parent.width - image.width
				Label {font.pixelSize: 24;  wrapMode: Text.Wrap; width: parent.width; text: headline}
				Label {font.pixelSize: 22;  wrapMode: Text.Wrap; width: parent.width; text: location}
				Label {font.pixelSize: 22;  wrapMode: Text.Wrap; width: parent.width; text: industry}
			}
		}

	}

}
